<template>
  <div class="card-table">
    <el-dialog
      :visible.sync="centerDialogVisible"
      width="25%"
      center
      :before-close="() => $emit('dialogQuxiao')"
    >
      <div class="header">
        <div
          style="
            margin-left: 11px;
            font-size: 17px;
            color: #22a1ff;
            font-weight: 500;
          "
        >
          {{ name }}工单
        </div>
      </div>
      <div class="main">
        <el-form
          size="small"
          :rules="rules"
          ref="form"
          :model="form"
          label-width="80px"
        >
          <el-form-item label="工单类型" prop="workOrderType">
            <el-input style="width: 300px" v-model="name" :disabled="true">
            </el-input>
          </el-form-item>

          <el-form-item
            :label="name == '出库' ? '出库数量' : '入库数量'"
            prop="number"
          >
            <el-input
              style="width: 300px"
              v-model="form.number"
              placeholder="请输入数量"
              clearable
            >
            </el-input>
          </el-form-item>
          <el-form-item label="外协地" prop="outside">
            <el-input
              style="width: 300px"
              v-model="form.outside"
              placeholder="请输入外协地"
              clearable
            >
            </el-input>
          </el-form-item>
          <el-form-item label="客户" prop="Customer">
            <el-input
              style="width: 300px"
              v-model="form.Customer"
              placeholder="请输入客户"
              clearable
            >
            </el-input>
          </el-form-item>
          <el-form-item label="批号" prop="lotNumber">
            <el-input
              style="width: 300px"
              v-model="form.lotNumber"
              placeholder="请输入批号"
              clearable
            >
            </el-input>
          </el-form-item>
          <el-form-item label="填写人员" prop="inputPeople">
            <el-input
              style="width: 300px"
              v-model="form.inputPeople"
              placeholder="请输入填写人"
            >
            </el-input>
          </el-form-item>

          <el-form-item label="备注" prop="remark">
            <el-input
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 4 }"
              style="width: 300px"
              v-model="form.remark"
            >
            </el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="$emit('dialogQuxiao'), (form = {})">取 消</el-button>
        <el-button type="primary" @click="resetForm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { NewLIUZHUANcreate } from "@/api/stock/banlance3.js";
export default {
  components: {},
  props: ["dialogVisible", "names", "rowa"],
  emits: ["dialogQuxiao"],
  data() {
    return {
      rules: {},
      centerDialogVisible: this.dialogVisible,
      name: this.names,
      form: {},
      row: this.rowa,
    };
  },
  computed: {},
  watch: {
    dialogVisible(n) {
      this.centerDialogVisible = n;
    },
    names(n) {
      this.name = n;
    },
    rowa(n) {
      if (n != 1) {
        console.log(n, 12);
        this.row = n;
      }
    },
  },
  created() {},
  mounted() {},
  methods: {
    async resetForm() {
      this.form.workOrderType = this.name;
      this.form.number = parseFloat(this.form.number);
      if (this.name == "入库") {
        this.form.gowhereCraft = this.row.craft;

        this.form.diameterIn = this.row.diameter;
        this.form.lengthIn = this.row.length;
        this.form.whatModelOut = this.row.whatModel;
        this.form.moldOut = this.row.mold;
        this.form.goodOut = this.row.goodOrBad;
        this.form.statusOut = this.row.status;
        this.form.affiliationOut = this.row.affiliation;
      } else {
        this.form.diameterOut = this.row.diameter;
        this.form.lengthOut = this.row.length;
        this.form.good = this.row.goodOrBad;
        this.form.whatModel = this.row.whatModel;
        this.form.mold = this.row.mold;
        this.form.status = this.row.status;
        this.form.affiliation = this.row.affiliation;
        this.form.originCraft = this.row.craft;
      }
      console.log(this.form, 2112);

      const { data } = await NewLIUZHUANcreate(this.form);
      if (data.code == 200) {
        this.$message({
          type: "success",
          message: `${this.name}${data.message}`,
        });
      } else {
        this.$message({
          type: "error",
          message: `${this.name}${data.message}`,
        });
      }
      this.form = {};
      this.$emit("dialogQuxiao");
    },
  },
};
</script>

<style  scoped>
.card-table {
  padding: 0;
}
.header {
  display: flex;
  align-items: center;
  padding: 18px;
  border-bottom: thin solid rgb(223, 223, 223);
}
.main {
  width: 800px;
  padding: 20px;

  .items {
    display: inline-block;
  }
}
.footer {
  padding: 20px;
}
</style>
